Build the Fact Table (the query)
If you have not done so already, please review the previous topic before starting this topic.
- On the Fact Table screen of the Build OLAP Cube dialog, click on the Build Query icon at the lower left to launch the Build Query dialog box that you have seen in previous examples.
- Build the query using the Employees, Locations, Regions, Orders, Order_Details, and Products tables.
- Join the tables as follows:
- Employees.emp_id with Orders.employee-id
- Employees.location_id with Locations.location_id
- Locations.region_id with Regions.region_id
- Orders.transaction_id with Order_Details.transaction_id
- Order_Details.product_id with Product.product_id
Your tables should look like the following:
- In the SELECT tab, enter the following fields by double-clicking them within their tables: Employees.last_name, Orders.sale_date, Products.product_name, and Regions.region_name.
- In the last column, select <calculated> in the Table field.
- Click the ellipses button to launch the SQL Editor.
- Multiply the unit price by the quantity to get the total sales in the <calculated> column:
Products.unit_price *Order_Details.quantity - Click OK to return to the Build Query editor.
- Enter 'sales_total' in the As field in the <calculated> column.
- Your SELECT clause should now look like this:
To set a condition to find only records where the sale_date is greater than the date input by the user:
- Click the WHERE tab.
- In the Orders table, double-click the sale_date field to autofill the query fields.
- Click the ellipses button in the Conditions field to launch the SQL Editor, and enter > (greater than) and click the user-defined variable button and select the date object you placed on your dashboard.
- Click OK to return to the Build Query editor.
- Click OK again to return to the OLAP cube builder.
- Click Next to continue.